<template>
	<view>
		<uni-ec-canvas class="uni-ec-canvas" id="uni-ec-canvas" ref="canvas" canvas-id="mychart-gauge" :ec="ec">
		</uni-ec-canvas>
	</view>
</template>

<script>
	import uniEcCanvas from './uni-ec-canvas/uni-ec-canvas.vue'
	import * as echarts from '../component/uni-ec-canvas/echarts.js'
	import {
		miniAppCurveStat
	} from '/api/index.js'
	let chart = null
	export default {
		components: {
			uniEcCanvas
		},
		props: {
			valueData: {
				type: Number,
				// 定义是否必须传
				required: true,
				// 定义默认值
				default: 0
			}
		},
		mounted() {
			this.$refs.canvas.init(this.initChart)
		},
		data() {
			return {
				ec: {
					//是否懒加载, 将 lazyLoad 设为 true 后，需要手动初始化图表
					lazyLoad: true
				},
			}
		},

		methods: {
			miniAppCurveStat(){
				miniAppCurveStat().then(res=>{
					
				})
			},
			initChart(canvas, width, height, canvasDpr) {
				chart = echarts.init(canvas, null, {
					width: width,
					height: height,
					devicePixelRatio: canvasDpr
				})
				canvas.setChart(chart)

				let option = {
					xAxis: {
						type: 'category',
						data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
					},
					yAxis: {
						type: 'value'
					},
					series: [{
						data: [150, 230, 224, 218, 135, 147, 260],
						type: 'line'
					}]
				};
				chart.setOption(option)
				return chart
			},
		},

	}
</script>
<style>
	.uni-ec-canvas {
		width: 100%;
		height: 500rpx;
		display: block;
		margin-top: 30rpx;
	}
</style>